﻿
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace WinnerCMS.Data.Mapping
{
    public partial class ShopMap
        : EntityTypeConfiguration<WinnerCMS.Model.Goods>
    {
        public ShopMap()
        {
            HasKey(t => t.Id);

            Property(t => t.GoodsNum)
                
                .HasMaxLength(20)
                .IsRequired();
            Property(t => t.Brand)
                
                .HasMaxLength(50)
                .IsOptional();
            Property(t => t.BrandId)
                
                .IsOptional();
            Property(t => t.Standard)
                
                .HasMaxLength(100)
                .IsRequired();
            Property(t => t.Packaging)
                
                .HasMaxLength(100)
                .IsRequired();
            Property(t => t.BarCode)
                .IsUnicode(false)
                .HasMaxLength(50)
                .IsRequired();
            Property(t => t.Content)
                .IsMaxLength()
                .IsRequired();
            Property(t => t.PriceMarket)
                
                .HasPrecision(19, 4)
                .IsRequired();
            Property(t => t.PriceMember)
                
                .HasPrecision(19, 4)
                .IsRequired();
            Property(t => t.Unit)
                
                .HasMaxLength(5)
                .IsRequired();
            Property(t => t.BigPicUrl)
                .IsUnicode(false)
                .HasMaxLength(255)
                .IsRequired();
            Property(t => t.Discount)
                
                .HasPrecision(18, 4)
                .IsRequired();
            Property(t => t.PresentExp)
                
                .IsRequired();
            Property(t => t.Stocks)
                
                .IsRequired();
            Property(t => t.AlarmNum)
                
                .IsRequired();
            Property(t => t.BuyTimes)
                
                .IsRequired();
            Property(t => t.Weight)
                
                .HasPrecision(18, 4)
                .IsRequired();
            Property(t => t.IsSpecialPrice)
                
                .IsRequired();

            // Relationships
            HasRequired(t => t.BrandInfo)
                     .WithMany(t => t.ShopList)
                     .HasForeignKey(d => d.BrandId);

            //InitializeMapping();
        }
    }
}

